/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.myfaces.extensions.cdi.forge.api;

import org.jboss.forge.project.dependencies.DependencyBuilder;

import java.util.Arrays;
import java.util.List;

/**
 * @author Cosmin Martinconi, 29.06.2011
 */
public class CodiDependency {

    private static final String MODULE_GROUP_ID = "org.apache.myfaces.extensions.cdi.modules";

    private String description;
    private DependencyBuilder api;
    private DependencyBuilder impl;

    private List<CodiDependency> subDependencyList;

    public CodiDependency(String description, String apiArtifactId, String implArtifactId) {
        this(description,
             DependencyBuilder.create().setGroupId(MODULE_GROUP_ID).setArtifactId(apiArtifactId),
             DependencyBuilder.create().setGroupId(MODULE_GROUP_ID).setArtifactId(implArtifactId)
        );
    }

    public CodiDependency(String description, DependencyBuilder api, DependencyBuilder impl) {
        this.description = description;
        this.api = api;
        this.impl = impl;
    }

    public CodiDependency(String description, CodiDependency[] subDependencies) {
        this.description = description;
        this.subDependencyList = Arrays.asList(subDependencies);
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public DependencyBuilder getApi() {
        return api;
    }

    public DependencyBuilder getImpl() {
        return impl;
    }

    public List<CodiDependency> getSubDependencyList() {
        return subDependencyList;
    }

    @Override
    public String toString() {
        return getDescription();
    }
}
